#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int k=0,s,a,b,c;
	cin>>s;
	for(int i=10000;i<=30000;i++)
	{
		a=i%1000;
		b=i%10000/10;
		c=i/100;
	if(a%s==0&&b%s==0&&c%s==0)
	{
		k++;
		printf("%d\n",i);
	}
	}
	if(k==0)
	{
		printf("No");
	}
	system("pause");
	return 0; 
}
